package com.example.cms.service.Impl;

import com.example.cms.dao.FeedBackDao;

import com.example.cms.entity.FeedBack;
import com.example.cms.pojo.QueryPage;
import com.example.cms.service.FeedBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service("FeedBackService")
@Transactional
public class FeedBacckServiceImpl implements FeedBackService {

    @Autowired
    private FeedBackDao feedBackDao;

    @Autowired
    FeedBackService feedBackService;

    @Override
    public List<FeedBack> selectFeedBack(Integer page) {
        int pagesize = feedBackService.CountPage();//得到总页码数
         List<FeedBack> list = new ArrayList<FeedBack>();

            list = feedBackDao.selectFeedBack(page);

        return list;
    }

    @Override
    public Integer CountPage() {
        int size = feedBackDao.getDateNum();
        int pageNum = 0;//页码数
        if(size % pageSize == 0) {
            pageNum = size / pageSize;
        }else {
            pageNum = size / pageSize + 1;
        }
        return pageNum;
    }
}
